<?php
include '../dbconnect.php';

// 获取 POST 请求中的 REVIEWS_ID
$gid = isset($_POST['SERVICE_ID']) ? $_POST['SERVICE_ID'] : '';
if (empty($gid)) {
    echo json_encode(array("status" => "error", "message" => "Invalid or missing SERVICE_ID"));
    exit;
}

// 使用预处理语句防止 SQL 注入
$sql = "UPDATE services SET IS_DELETE = 1 WHERE SERVICE_ID = ?";
$stmt = $conn->prepare($sql);

if ($stmt === false) {
    echo json_encode(array("status" => "error", "message" => "Failed to prepare statement: " . $conn->error));
    exit;
}

// 绑定参数
$stmt->bind_param("s", $gid);

if ($stmt->execute()) {
    // 删除成功
    echo json_encode(array("status" => "success", "message" => "service deleted successfully"));
} else {
    // 删除失败
    echo json_encode(array("status" => "error", "message" => "Failed to delete service: " . $stmt->error));
}

$stmt->close();
$conn->close();
?>